﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using System.Web;
using ContractSingTowerMall;
using FacadeSingTowerMall;
using DTOSingTowerMall;
using System.IO;
using System.Web.Hosting;

namespace ServiceHostSingTowerMall
{
  
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single,ConcurrencyMode=ConcurrencyMode.Multiple)]
    public class ShoppingMallService : IShoppingMallService
    {
        public string GetData(int value)
        {
            return string.Format("You entered: {0}", value);
        }

        public ShoppingMall  GetShoppingMallDetails()
        {
            MallInfoFacade mif = new MallInfoFacade();
            /* Added for easy debug need to be removed on deployment */
            string root = HostingEnvironment.MapPath("~");
            string parent = Path.GetDirectoryName(Path.GetDirectoryName(root));

            /***************************************************/
            IMallInfo mallInfo = mif.getMallInfo(parent + "\\Database\\MallInfo.xml");
            ShoppingMallAdapter sma = new ShoppingMallAdapter();
            ShoppingMall sm = sma.GetShoppingMall(mallInfo);
            return sm;
        }
    }
}
